#ifndef _STRAWGUI_TEXT_RECT_H_
#define _STRAWGUI_TEXT_RECT_H_

#include "sConfig.h"
#include "sMath.h"
#include "sSaveable.h"

#ifdef _EDITOR
#include "sRTTIObject.h"
#endif

#include "sComponentRect.h"
#include "sFont.h"
#include "sPresetGroup.h"

namespace sgui
{
namespace res
{
	static const float FONT_ALIGN_COEF[3] = {0.f, 0.5f, 1.f};
	static const wchar_t TEXT_RETURN_CHAR = L'\n';

    typedef enum
    {
        VFA_TOP = 0,
        VFA_MIDDLE,
        VFA_BOTTOM
    } EVerticalFontAlign;

    typedef enum
    {
        HFA_LEFT = 0,
        HFA_CENTER,
        HFA_RIGHT
    } EHorisontalFontAlign;

	class sComponentRectText : public sComponentRect
	{
	private:
		preset::sGroup<preset::sFontPreset>		m_fontPreset;
		std::wstring							m_text;
		bool									m_wordWrap;
        EVerticalFontAlign						m_verticalAlign;
        EHorisontalFontAlign					m_horisontalAlign;

	public:
		preset::sGroup<preset::sFontPreset>&	getFontPresetGroup();
		const preset::sGroup<preset::sFontPreset>&	getFontPresetGroup() const;

		const std::wstring& getText() const;
		void setText(const std::wstring& name);
		const bool& getWordWrap() const;
		void setWordWrap(const bool& wordWrap);
        void setVerticalAlign(const EVerticalFontAlign& align) { m_verticalAlign = align; }
        const EVerticalFontAlign& getVerticalAlign() const { return m_verticalAlign; }
        void setHorisontalAlign(const EHorisontalFontAlign& align) { m_horisontalAlign = align; }
        const EHorisontalFontAlign& getHorisontalAlign() const { return m_horisontalAlign; }
		
		inst::sComponentRectInstance* getInstance(inst::sComponentInstance& instanceFor, s32 id) const;
		const EComponentRectType getClass() const { return COMPONENT_RECT_TEXT; }
		
		void save(db::Record& file) const;
		void load(const db::Record& file);
		void clear();
		
#ifdef _EDITOR
		void exportRTTI(rtti::sInfoList& list);
#endif
		sComponentRectText(sGUI& gui);

	};

};
};

#endif